<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:ry="">
	<head>
		<th:block th:include="include :: header('修改参数')" />
	</head>
	<body class="white-bg">
	    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
	        <form class="form-horizontal m" id="form-config-edit">
	            <input type="hidden" id="config_id" name="config_id" th:value="${map['config_id']}"/>
	            <div class="form-group">
	                <label class="col-sm-3 control-label is-required">参数名称：</label>
	                <div class="col-sm-8">
	                    <input type="text" name="config_name" class="form-control" th:value="${map['config_name']}" required/>
	                </div>
	            </div>
	            <div class="form-group">
	                <label class="col-sm-3 control-label is-required">参数键名：</label>
	                <div class="col-sm-8">
	                    <input type="text" id="config_key" name="config_key" class="form-control" th:value="${map['config_key']}" required/>
	                </div>
	            </div>
	            <div class="form-group">
	                <label class="col-sm-3 control-label is-required">参数键值：</label>
	                <div class="col-sm-8">
	                    <input type="text" name="config_value" class="form-control" th:value="${map['config_value']}" required/>
	                </div>
	            </div>
				<div class="form-group">
					<label class="col-sm-3 control-label is-required">系统内置：</label>
					<div class="col-sm-8">
					    <ry:radioDict dictType="sys_yes_no" name="config_type" class="radio-box" required="true" th:value="${map['config_type']}"/>
					</div>
				</div>
				<div class="form-group">
		            <label class="col-sm-3 control-label">备注：</label>
		            <div class="col-sm-8">
		                <textarea id="remark" name="remark" class="form-control" style="height: 150px;">[[${map['remark']}]]</textarea>
		            </div>
		        </div>
	    	</form>
	    </div>
	    <th:block th:include="include :: footer" />
	    <script type="text/javascript">
		    var prefix = ctx + "system/param";

		    $("#form-config-edit").validate({
		    	onkeyup: false,
		        rules: {
		            config_key: {
		                remote: {
		                    url: prefix + "/checkConfigKeyUnique",
		                    type: "post",
		                    dataType: "json",
		                    data: {
		                        "config_id": function() {
		                        	return $("#config_id").val();
		                        },
		                        "config_key": function() {
		                        	return $.common.trim($("#config_key").val());
		                        }
		                    },
		                    dataFilter: function(data, type) {
		                        return $.validate.unique(data);
		                    }
		                }
		            },
		        },
		        messages: {
		            "config_key": {
		                remote: "参数键名已经存在"
		            }
		        },
		        focusCleanup: true
		    });

		    function submitHandler() {
		        if ($.validate.form()) {
		        	$.operate.save(prefix + "/save", $('#form-config-edit').serialize());
		        }
		    }
	    </script>
	</body>
</html>